function openwindows(url,da,$){
    $.ajax({
        url:url,
        type:"post",
        data:da,
        success:function(data){
            $("#body").html(data);
        },
        error:function(){
            layer.msg("服务器错误！");
        }
    })
}

function ajaxUtil(url , data , fun , obj){
    $.ajax({
        url:url,
        type:"post",
        data:data,
        success:function(data){
            if(data=="success"){
                fun(obj)
            }else{
                codeAlert(data);
            }
        },
        error:function(xh){
            layer.alert('连接服务器错误！错误编码:'+xh.status, {icon: 2});
        }
    })
}

function codeAlert(code){
    if(code == "004"){
        layer.alert('修改失败', {icon: 2});
        return false;
    }
    if(code == "005"){
        layer.alert('新增失败', {icon: 2});
        return false;
    }
    if(code == "006"){
        layer.alert('没有该父级菜单', {icon: 2});
        return false;
    }
    if(code == "007"){
        layer.alert('删除失败', {icon: 2});
        return false;
    }
    if(code == "008"){
        layer.alert('名称重复操作失败', {icon: 2});
        return false;
    }
    layer.alert('错误编码：'+code, {icon: 2});
}

Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
layui.use(['jquery'],function(){
    var $ = layui.jquery;
        $.fn.serializeJson=function(){
            var serializeObj={};
            var array=this.serializeArray();
            var str=this.serialize();
            $(array).each(function(){
                if(serializeObj[this.name]){
                    if($.isArray(serializeObj[this.name])){
                        serializeObj[this.name].push(this.value);
                    }else{
                        serializeObj[this.name]=[serializeObj[this.name],this.value];
                    }
                }else{
                    serializeObj[this.name]=this.value;
                }
            });
            return serializeObj;
        };
});